package com.bf.electroplating.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.bf.electroplating.pojo.entity.PubAttachment;
import com.bf.electroplating.pojo.vo.ResultVO;
import com.bf.electroplating.pojo.vo.attachment.AttachmentVo;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.List;

/**
* @author 15451
* @description 针对表【pub_attachment(附件表)】的数据库操作Service
* @createDate 2025-05-09 11:11:32
*/
public interface PubAttachmentService extends IService<PubAttachment> {

    void download( String id , HttpServletResponse response ) throws Exception;
    ResultVO<AttachmentVo> uploadFile(MultipartFile multipartFile ) throws IOException;
    ResultVO < String > getFileUrl( String id );
    /**
     * 根据id和模块获取文件(一对一单个的)
     */
    AttachmentVo getOneFile( String id , String module );
    /**
     * 根据id和模块获取全部文件(一对多的)
     */
    List< AttachmentVo > getWholeFile(String id , String module );

    /**
     * 保存附件表相关 单个
     * attachmentVo 文件vo
     * id 关联数据id
     * module 模块
     */

    void saveOnePubAttachmentRel( AttachmentVo attachmentVo , String id , String module );

    /**
     * 保存附件表相关 多个
     *  attachmentVo 文件voList
     * 	id 关联数据id
     * 	module 模块
     */

    void saveWholeAttachmentRel( List < AttachmentVo > attachmentVos , String id , String module );

    /**
     * 根据id获取全部文件(一对多的)
     */
    List < AttachmentVo > getByIdFile( String id );

    void deleteByModuleId(String id, String code);

    /**
     * 从文件路径上传附件并关联到指定关系
     * @param filePath 文件路径
     * @param relationId 关联ID
     * @param module 模块代码
     * @return 附件ID
     */
    String uploadFileFromPath(String filePath, String relationId, String module);

    String uploadFileToTargetMinio(MultipartFile file, String attachmentType, String id);

    /**
     * 更新附件
     * @param id 附件ID
     * @param file 新的文件
     * @return 更新后的附件信息
     */
    ResultVO<AttachmentVo> updateAttachment(String id, MultipartFile file) throws IOException;
}
